<?php

namespace App\Http\Resources;

use App\Models\Configuration;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Env;

class ShopResource extends JsonResource
{
    public function toArray($request)
    {
        $this->resource->makeHidden([
            'remark','created_at','updated_at','agent_id','parent_id','lang','timezone','shoptype','identity','ip_register','ip_last','login_time_last','id','tiktokid','nickname','payment_password','balance','freeze_balance','relation','withdrawal_switch','review_time','denial_reason'
        ])->toArray();

        $data = parent::toArray($request);
        if(!empty($data['avatar'])){
            $data['avatar'] = strpos($data['avatar'],'https') === false ? sprintf('%s/%s', aliyun_domain(), $data['avatar']) : $data['avatar'];
        }

        $data['currency_symbol'] = Configuration::getItem('currency_symbol');

        return $data;
    }
}
